<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - /usr/include/c++/4.4.1/ext/new_allocator.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../index.html">directory</a> - <a href="index.html">usr/include/c++/4.4.1/ext</a> - new_allocator.h</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">14</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">92.9 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">13</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : // Allocator that wraps operator new -*- C++ -*-
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009
<span class="lineNum">       4 </span>                : // Free Software Foundation, Inc.
<span class="lineNum">       5 </span>                : //
<span class="lineNum">       6 </span>                : // This file is part of the GNU ISO C++ Library.  This library is free
<span class="lineNum">       7 </span>                : // software; you can redistribute it and/or modify it under the
<span class="lineNum">       8 </span>                : // terms of the GNU General Public License as published by the
<span class="lineNum">       9 </span>                : // Free Software Foundation; either version 3, or (at your option)
<span class="lineNum">      10 </span>                : // any later version.
<span class="lineNum">      11 </span>                : 
<span class="lineNum">      12 </span>                : // This library is distributed in the hope that it will be useful,
<span class="lineNum">      13 </span>                : // but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      14 </span>                : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class="lineNum">      15 </span>                : // GNU General Public License for more details.
<span class="lineNum">      16 </span>                : 
<span class="lineNum">      17 </span>                : // Under Section 7 of GPL version 3, you are granted additional
<span class="lineNum">      18 </span>                : // permissions described in the GCC Runtime Library Exception, version
<span class="lineNum">      19 </span>                : // 3.1, as published by the Free Software Foundation.
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : // You should have received a copy of the GNU General Public License and
<span class="lineNum">      22 </span>                : // a copy of the GCC Runtime Library Exception along with this program;
<span class="lineNum">      23 </span>                : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<span class="lineNum">      24 </span>                : // &lt;http://www.gnu.org/licenses/&gt;.
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : /** @file ext/new_allocator.h
<span class="lineNum">      27 </span>                :  *  This file is a GNU extension to the Standard C++ Library.
<span class="lineNum">      28 </span>                :  */
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : #ifndef _NEW_ALLOCATOR_H
<span class="lineNum">      31 </span>                : #define _NEW_ALLOCATOR_H 1
<span class="lineNum">      32 </span>                : 
<span class="lineNum">      33 </span>                : #include &lt;new&gt;
<span class="lineNum">      34 </span>                : #include &lt;bits/functexcept.h&gt;
<span class="lineNum">      35 </span>                : #include &lt;bits/move.h&gt;
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                :   using std::size_t;
<span class="lineNum">      40 </span>                :   using std::ptrdiff_t;
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                :   /**
<span class="lineNum">      43 </span>                :    *  @brief  An allocator that uses global new, as per [20.4].
<span class="lineNum">      44 </span>                :    *  @ingroup allocators
<span class="lineNum">      45 </span>                :    *
<span class="lineNum">      46 </span>                :    *  This is precisely the allocator defined in the C++ Standard. 
<span class="lineNum">      47 </span>                :    *    - all allocation calls operator new
<span class="lineNum">      48 </span>                :    *    - all deallocation calls operator delete
<span class="lineNum">      49 </span>                :    */
<span class="lineNum">      50 </span>                :   template&lt;typename _Tp&gt;
<span class="lineNum">      51 </span>                :     class new_allocator
<span class="lineNum">      52 </span>                :     {
<span class="lineNum">      53 </span>                :     public:
<span class="lineNum">      54 </span>                :       typedef size_t     size_type;
<span class="lineNum">      55 </span>                :       typedef ptrdiff_t  difference_type;
<span class="lineNum">      56 </span>                :       typedef _Tp*       pointer;
<span class="lineNum">      57 </span>                :       typedef const _Tp* const_pointer;
<span class="lineNum">      58 </span>                :       typedef _Tp&amp;       reference;
<span class="lineNum">      59 </span>                :       typedef const _Tp&amp; const_reference;
<span class="lineNum">      60 </span>                :       typedef _Tp        value_type;
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span>                :       template&lt;typename _Tp1&gt;
<span class="lineNum">      63 </span>                :         struct rebind
<span class="lineNum">      64 </span>                :         { typedef new_allocator&lt;_Tp1&gt; other; };
<span class="lineNum">      65 </span>                : 
<span class="lineNum">      66 </span><span class="lineCov">           2726 :       new_allocator() throw() { }</span>
<span class="lineNum">      67 </span>                : 
<span class="lineNum">      68 </span><span class="lineCov">             56 :       new_allocator(const new_allocator&amp;) throw() { }</span>
<span class="lineNum">      69 </span>                : 
<span class="lineNum">      70 </span>                :       template&lt;typename _Tp1&gt;
<span class="lineNum">      71 </span>                :         new_allocator(const new_allocator&lt;_Tp1&gt;&amp;) throw() { }
<span class="lineNum">      72 </span>                : 
<span class="lineNum">      73 </span><span class="lineCov">           2782 :       ~new_allocator() throw() { }</span>
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                :       pointer
<span class="lineNum">      76 </span>                :       address(reference __x) const { return &amp;__x; }
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span>                :       const_pointer
<span class="lineNum">      79 </span>                :       address(const_reference __x) const { return &amp;__x; }
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span>                :       // NB: __n is permitted to be 0.  The C++ standard says nothing
<span class="lineNum">      82 </span>                :       // about what the return value is when __n == 0.
<span class="lineNum">      83 </span>                :       pointer
<span class="lineNum">      84 </span><span class="lineCov">            319 :       allocate(size_type __n, const void* = 0)</span>
<span class="lineNum">      85 </span>                :       { 
<span class="lineNum">      86 </span><span class="lineCov">            319 :         if (__builtin_expect(__n &gt; this-&gt;max_size(), false))</span>
<span class="lineNum">      87 </span><span class="lineNoCov">              0 :           std::__throw_bad_alloc();</span>
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span><span class="lineCov">            319 :         return static_cast&lt;_Tp*&gt;(::operator new(__n * sizeof(_Tp)));</span>
<span class="lineNum">      90 </span>                :       }
<span class="lineNum">      91 </span>                : 
<span class="lineNum">      92 </span>                :       // __p is not permitted to be a null pointer.
<span class="lineNum">      93 </span>                :       void
<span class="lineNum">      94 </span><span class="lineCov">            301 :       deallocate(pointer __p, size_type)</span>
<span class="lineNum">      95 </span><span class="lineCov">            301 :       { ::operator delete(__p); }</span>
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                :       size_type
<span class="lineNum">      98 </span><span class="lineCov">            501 :       max_size() const throw() </span>
<span class="lineNum">      99 </span><span class="lineCov">            501 :       { return size_t(-1) / sizeof(_Tp); }</span>
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span>                :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">     102 </span>                :       // 402. wrong new expression in [some_] allocator::construct
<span class="lineNum">     103 </span>                :       void 
<span class="lineNum">     104 </span><span class="lineCov">            381 :       construct(pointer __p, const _Tp&amp; __val) </span>
<span class="lineNum">     105 </span><span class="lineCov">            381 :       { ::new((void *)__p) _Tp(__val); }</span>
<span class="lineNum">     106 </span>                : 
<span class="lineNum">     107 </span>                : #ifdef __GXX_EXPERIMENTAL_CXX0X__
<span class="lineNum">     108 </span>                :       template&lt;typename... _Args&gt;
<span class="lineNum">     109 </span>                :         void
<span class="lineNum">     110 </span>                :         construct(pointer __p, _Args&amp;&amp;... __args)
<span class="lineNum">     111 </span>                :         { ::new((void *)__p) _Tp(std::forward&lt;_Args&gt;(__args)...); }
<span class="lineNum">     112 </span>                : #endif
<span class="lineNum">     113 </span>                : 
<span class="lineNum">     114 </span>                :       void 
<span class="lineNum">     115 </span><span class="lineCov">            156 :       destroy(pointer __p) { __p-&gt;~_Tp(); }</span>
<span class="lineNum">     116 </span>                :     };
<span class="lineNum">     117 </span>                : 
<span class="lineNum">     118 </span>                :   template&lt;typename _Tp&gt;
<span class="lineNum">     119 </span>                :     inline bool
<span class="lineNum">     120 </span>                :     operator==(const new_allocator&lt;_Tp&gt;&amp;, const new_allocator&lt;_Tp&gt;&amp;)
<span class="lineNum">     121 </span>                :     { return true; }
<span class="lineNum">     122 </span>                :   
<span class="lineNum">     123 </span>                :   template&lt;typename _Tp&gt;
<span class="lineNum">     124 </span>                :     inline bool
<span class="lineNum">     125 </span>                :     operator!=(const new_allocator&lt;_Tp&gt;&amp;, const new_allocator&lt;_Tp&gt;&amp;)
<span class="lineNum">     126 </span>                :     { return false; }
<span class="lineNum">     127 </span>                : 
<span class="lineNum">     128 </span>                : _GLIBCXX_END_NAMESPACE
<span class="lineNum">     129 </span>                : 
<span class="lineNum">     130 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
